package com.sky.mapper.admin;


import com.github.pagehelper.Page;
import com.sky.aop.AutoFill;
import com.sky.dto.EmployeePageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Employee;
import org.apache.ibatis.annotations.*;



public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     * @param username
     * @return
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 新增员工
     * @param employee
     */
    @AutoFill(OperationType.INSERT)
    @Insert("insert into employee ( name, username, password, phone, sex, id_number, status, create_time, update_time, create_user, update_user) " +
            "values (#{name},#{username},#{password},#{phone},#{sex},#{idNumber},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void add(Employee employee);

    /**
     * 员工分页条件查询
     * @return
     */
    Page<Employee> page(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 禁用员工启用员工
     *
     * @param id
     * @param status
     */
    @Update("update employee set status =#{status} where id=#{id}")
    void disable(Integer id, Integer status);

    /**
     * 查询回显
     * @param id
     * @return
     */
    @Select("select * from employee where id =#{id}")
    Employee getById(Integer id);

    /**
     * 修改员工
     * @param employee
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);
}
